package com.sky.Screen;

import android.app.ActivityGroup;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TabHost;
import android.widget.TabHost.OnTabChangeListener;
import android.widget.TabHost.TabSpec;
import android.widget.TextView;

import com.healthcare.widget.ActionBar;
import com.healthcare.widget.ActionBar.IntentAction;
import com.sky.heathcare.HealthCareApp;
import com.sky.heathcare.R;

public class KnowlegeActivity extends ActivityGroup {
	
	public static TabHost tabHost;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.knowlege_activity);
		
		final ActionBar actionBar = (ActionBar) findViewById(R.id.actionbar);       
        actionBar.setTitle("Kien thuc");

        actionBar.setHomeAction(new IntentAction(this, MainActivity.createIntent(this), R.drawable.ic_title_home_default));
        actionBar.setDisplayHomeAsUpEnabled(true);
        
		tabHost=(TabHost)findViewById(R.id.mainTab);
		tabHost.setup(this.getLocalActivityManager());

		tabHost.setOnTabChangedListener(new OnTabChangeListener() {

			public void onTabChanged(String tabId) {
				// TODO Auto-generated method stub	
				HealthCareApp app = (HealthCareApp)getApplicationContext();
				if(app != null)
					app.nCurrentTabPos = tabHost.getCurrentTab();
				
			}
		});
		
		Intent videoIntent;
    	videoIntent = new Intent().setClass(this, ListSubjectActivity.class);
    	String[] arr = {"Kieng cu","Bai thuoc","van dong"};
    	int nSize = arr.length;
    	for(int i = 0; i< nSize; i++)
    	{	 	
    		videoIntent.putExtra("TAB_POS", i);    		
    		setupTab(new TextView(this), arr[i], videoIntent);
    	}
    	    
		}

	
	private void setupTab(final View view, final String tag, final Intent myIntent) {

		View tabview = createTabView(tabHost.getContext(), tag);
		TabSpec setContent =  tabHost.newTabSpec(tag)
									  .setIndicator(tabview)										  
									  .setContent(myIntent);
		tabHost.addTab(setContent);
		
		//mTabHost.getTabWidget().getChildAt(0).getLayoutParams().height =30;
	}

 private static View createTabView(final Context context, final String text) {
		View view = LayoutInflater.from(context).inflate(R.layout.tabs_bg, null);//history: video_tab_layout
		TextView tv = (TextView) view.findViewById(R.id.tabsText);
		tv.setText(text);
		return view;
	}
 
	private void gotoMainScreen() {
		Intent intent = new Intent(this, MainActivity.class);		
		startActivity(intent);	
	}

	    
	
}
